package com.android.duininsuoai.adapt;

import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.duininsuoai.R;
import com.android.duininsuoai.model.detail.DirectBuyGoodsDetail;
import com.android.duininsuoai.utils.ObjectUtils;

import java.util.List;

/**
 * Created by Administrator on 2016/8/10.
 */
public class GridDirectBuyGoodsDetaillikeAdapt extends BaseAdapter {
    private LayoutInflater Inflater;
    private Context content;
    private List<DirectBuyGoodsDetail.DataBean.TjListBean> listdata;

    public GridDirectBuyGoodsDetaillikeAdapt(Context content, List<DirectBuyGoodsDetail.DataBean.TjListBean> listdata) {
        this.listdata = listdata;
        this.content = content;
        this.Inflater = LayoutInflater.from(content);
    }
    @Override
    public int getCount() {
            return listdata==null? 0:listdata.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {


        ViewHolder holder = null;
        holder = new ViewHolder();
        if (convertView == null) {

            convertView = Inflater.inflate(R.layout.item_grid_directbuy_goodsdetail_like, null);

            holder.item_grid_detail_like_img = (ImageView) convertView.findViewById(R.id.item_grid_detail_like_img);
            holder.item_grid_detail_like_title = (TextView) convertView.findViewById(R.id.item_grid_detail_like_title);
            holder.item_grid_detail_like_number_after = (TextView) convertView.findViewById(R.id.item_grid_detail_like_number_after);
            holder.item_grid_detail_like_number_before = (TextView) convertView.findViewById(R.id.item_grid_detail_like_number_before);


            convertView.setTag(holder);
        } else {

            holder = (ViewHolder) convertView.getTag();

        }
        holder.item_grid_detail_like_number_before.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

        DirectBuyGoodsDetail.DataBean.TjListBean mainlistdata = listdata.get(position);
        holder.item_grid_detail_like_title.setText(mainlistdata.getName());
        ObjectUtils.photo2(content, mainlistdata.getImg_cover(), holder.item_grid_detail_like_img);
        holder.item_grid_detail_like_number_after.setText("￥" + mainlistdata.getTeam_price());

        holder.item_grid_detail_like_number_before.setText("￥" +  mainlistdata.getPrice());

        return convertView;
    }

    static class ViewHolder {

        ImageView item_grid_detail_like_img;
        TextView item_grid_detail_like_title;
        TextView item_grid_detail_like_number_after;
        TextView item_grid_detail_like_number_before;


    }
}
